﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第八十题
//BC82(a + b - c)* d的计算问题
//https://www.nowcoder.com/practice/9df4b80fc3ab475288e5c26972440e1b?tpId=107&tqId=33363&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    while (scanf("%d %d %d %d", &a, &b, &c, &d) != EOF) {
        printf("%d\n", (a + b - c) * d);
    }
    return 0;
}